Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.ExpressApp.Editors

Public Class PopupNotesController
    Inherits DevExpress.ExpressApp.ViewController

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)

    End Sub

    Private Sub ShowNotesAction_CustomizePopupWindowParams(ByVal sender As Object, _
ByVal e As CustomizePopupWindowParamsEventArgs) _
Handles ShowNotesAction.CustomizePopupWindowParams
        Dim objectSpace As IObjectSpace = Application.CreateObjectSpace()
        'e.View = Application.CreateListView(Application.FindListViewId(GetType(Note)), _
        'New CollectionSource(objectSpace, GetType(Note)), True)
    End Sub


    Private Sub ShowNotesAction_Execute(ByVal sender As Object, _
 ByVal e As PopupWindowShowActionExecuteEventArgs) Handles ShowNotesAction.Execute
        Dim task As DemoTask = CType(View.CurrentObject, DemoTask)
        View.ObjectSpace.SetModified(task)
        For Each note As Note In e.PopupWindow.View.SelectedObjects
            If (Not String.IsNullOrEmpty(task.Description)) Then
                task.Description += Environment.NewLine
            End If
            task.Description += note.Text
        Next note
        Dim item As ViewItem = (CType(View, DetailView)).FindItem("Description")
        CType(item, PropertyEditor).ReadValue()
        'Save changes to the database if the current Detail View is displayed in the View mode
        If TypeOf View Is DetailView AndAlso (CType(View, DetailView)).ViewEditMode = _
            ViewEditMode.View Then
            View.ObjectSpace.CommitChanges()
        End If
    End Sub

End Class
